<?php

/**
 * Usuario form base class.
 *
 * @package    form
 * @subpackage usuario
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 8508 2008-04-17 17:39:15Z fabien $
 */
class BaseUsuarioForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'cd_usuario'       => new sfWidgetFormInputHidden(),
      'cd_tipo_usuario'  => new sfWidgetFormDoctrineChoice(array('model' => 'TipoUsuario', 'add_empty' => false)),
      'name'             => new sfWidgetFormInput(),
      'no_email'         => new sfWidgetFormInput(),
      'telefone'         => new sfWidgetFormInput(),
      'co_senha'         => new sfWidgetFormInput(),
      'dt_ultimo_acesso' => new sfWidgetFormDateTime(),
      'reset_senha'      => new sfWidgetFormInputCheckbox(),
      'deleted'          => new sfWidgetFormInputCheckbox(),
      'created_at'       => new sfWidgetFormDateTime(),
      'updated_at'       => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'cd_usuario'       => new sfValidatorDoctrineChoice(array('model' => 'Usuario', 'column' => 'cd_usuario', 'required' => false)),
      'cd_tipo_usuario'  => new sfValidatorDoctrineChoice(array('model' => 'TipoUsuario')),
      'name'             => new sfValidatorString(array('max_length' => 255)),
      'no_email'         => new sfValidatorString(array('max_length' => 255)),
      'telefone'         => new sfValidatorInteger(array('required' => false)),
      'co_senha'         => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'dt_ultimo_acesso' => new sfValidatorDateTime(array('required' => false)),
      'reset_senha'      => new sfValidatorBoolean(),
      'deleted'          => new sfValidatorBoolean(),
      'created_at'       => new sfValidatorDateTime(array('required' => false)),
      'updated_at'       => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Usuario', 'column' => array('no_email')))
    );

    $this->widgetSchema->setNameFormat('usuario[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Usuario';
  }

}
